# coding:UTF-8
# ________________________
# Project_Name:pythonProject
# File_Name:Administrator
# Author:Administrator
# Date_Time:2022/4/22 16:19
# Description:
# ________________________
from selenium import webdriver
import time
from selenium.webdriver.common.by import By



def  foo1():
    """"

    """
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get(r"http://news.baidu.com/")

    #循环打开6个热点新闻
    for i in range(1,7):
        driver.find_element(By.XPATH,f'//*[@id="pane-news"]/div/ul/li[{i}]').click()
    time.sleep(3)


    # #获取所有窗口的handle
    # handles = driver.window_handles
    # print(handles)
    #
    # #循环切换窗口
    # for handle in handles:
    #     driver.switch_to.window(handle)
    #     #根据页面url或者title判断页面
    #     if driver.current_url == "https://news.cctv.com/2022/04/22/ARTIvl4KswVg2nPGggIBaY24220422.shtml":
    #         break
    #     time.sleep(1)




    driver.quit()




if  __name__=="__main__":
    foo1()


